const { expect,BigNumber } = require("chai");
const { ethers } = require("hardhat");


describe("ArrtibuteAssert",async function () {

  it("verify Arrtibute constructor", async function () {
    const [owner, addr1,addr2] = await ethers.getSigners();
    console.log("[INFO]get owner & addr1 :"+owner.address +" & "+addr1.address +" & "+addr2.address);

    const trait_type = 0;
    const AssertIndex = 0; 
    const ArrtibuteAssert = await ethers.getContractFactory("ArrtibuteAssert");
    const arrtibuteAssert = await ArrtibuteAssert.deploy(
      owner.address,
      trait_type,
      AssertIndex,
      "cris",
      "QmVVKDkMziAXLmSyfhFAF5ev9TNyXVe6dkMGA6YNbRcQSv",
      "QmXuz6bWxYuB1atjpYt1WJsiT2yfnJ38qHDXWur65fXAsR",
      10,
      "MonkeyKing Head",
      "HKH",
    );

    await arrtibuteAssert.deployed();

    expect(await arrtibuteAssert.getArtist()).to.equal(owner.address);
    expect(await arrtibuteAssert.getArtwork_name()).to.equal("cris");
    expect(await arrtibuteAssert.getArtwork_image_uri()).to.equal("QmVVKDkMziAXLmSyfhFAF5ev9TNyXVe6dkMGA6YNbRcQSv");
    expect(await arrtibuteAssert.getArtwork_metadata_uri()).to.equal("QmXuz6bWxYuB1atjpYt1WJsiT2yfnJ38qHDXWur65fXAsR");
    
  });

  it("Execute safeMint and get correct tokenId", async function () {
    const IssueLimition = 10;
    const [owner, user1,user2] = await ethers.getSigners();
    const trait_type = 0;
    const AssertIndex = 0; 
    const ArrtibuteAssert = await ethers.getContractFactory("ArrtibuteAssert");
    const arrtibuteAssert = await ArrtibuteAssert.deploy(
      owner.address,
      trait_type,
      AssertIndex,
      "cris",
      "QmVVKDkMziAXLmSyfhFAF5ev9TNyXVe6dkMGA6YNbRcQSv",
      "QmXuz6bWxYuB1atjpYt1WJsiT2yfnJ38qHDXWur65fXAsR",
      10,
      "MonkeyKing Head",
      "HKH",
    );
    await arrtibuteAssert.deployed();

    let _tokenId = 1;
   
    // console.log("[INFO] tx:" +Object.entries(tokenId));
    // console.log("[INFO] nextTokenId:"+Object.entries(await arrtibuteAssert.getNextTokenId())); // return bigNumber
    
    expect(await arrtibuteAssert.getNextTokenId()).to.equal(_tokenId);

    for(let i = 0;i<IssueLimition;i++){
      _tokenId++;
      const safeMintTx = await  arrtibuteAssert.safeMint(user1.address);
      const tx = await safeMintTx.wait();
      expect(await arrtibuteAssert.getNextTokenId()).to.equal(_tokenId);
    }
  });

});